package com.project.nimsen.service.impl;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import com.project.jdbc.dao.IBaseJdbcDao;
import com.project.jdbc.service.BaseServiceImpl;
import com.project.jdbc.utils.Finder;
import com.project.nimsen.dao.IBaseDao;
import com.project.nimsen.entity.SUserEntity;
import com.project.nimsen.service.ISUserService;
@Repository("sUserService")
public class SUserServiceImpl extends BaseServiceImpl implements ISUserService {
	@Resource
	IBaseDao baseDao;
	protected IBaseJdbcDao getBaseDao() {
		return baseDao;
	}
	public SUserEntity findByUserName(String username) throws Exception {
		Finder finder = new Finder("select * from S_USER where active=0 and USER_NAME=:USER_NAME");
		finder.setParam("USER_NAME", username);
		return baseDao.queryForObject(finder, SUserEntity.class);
	}
	public SUserEntity findById(String id) throws Exception {
		if(StringUtils.isBlank(id)){
			return null;
		}
		Finder finder = new Finder("select * from S_USER where id=:id");
		finder.setParam("id", id);
		return baseDao.queryForObject(finder, SUserEntity.class);
	}
}
